package upm.pb4agent.team5.common;

import java.util.Date;

import jade.domain.FIPAException;
import upm.pb4agent.team5.BaseAgent;

public class RegistrationDesk extends BaseAgent {
	private static final long serialVersionUID = 7093507070267639113L;
	public final static String DF_NAME = "RegistrationDesk";
	
    private Date registerTime = null;
	
    public RegistrationDesk() {
		super(DF_NAME);
	}
    
	/**
     * Method executed when agent is initialized
     */
	protected void setup() {
		System.out.println(getLocalName() + ": Enters the system");

		try {
			registerAgent();
			System.out.println(getLocalName() + ": Registered in DF");
			
			// Adding behavior to manipulate team inscriptions
			registerTime = new Date();
			addBehaviour(new BRegistrationDeskManageInscription(this, registerTime));		
		} catch (FIPAException e) {
			System.err.println(getLocalName()+": Cannot register in DF");
			doDelete(); // Terminating agent
		}
	}
	
}
